#!coding=utf-8
from django.conf.urls import patterns, include, url
import views
import sys,os
from django.http import *
from django.db import transaction
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    url(r'^$', 'views.login'),
    url(r'^/$', 'views.login'),
    url(r'^login/$', 'views.login'),
    url(r'^loginAdmin/$', 'views.loginAdmin'),
    url(r'^loginOut/(\d{1})$', 'views.loginOut'),
    url(r'^loginSA/$','views.loginSA'),

    url(r'^admin/parkDetail/(.+)/$', 'views.parkDetail'),
    url(r'^admin/parkList/$','views.parkList'),
    url(r'^admin/parkEdit/(.+)/$','views.parkEdit'),
    url(r'^admin/submitEidtPark/$','views.submitEidtPark'),
    url(r'^admin/parkDelete/(.+)/$','views.parkDelete'),

    url(r'^admin/addPark/$', 'views.addPark'),
    url(r'^admin/myadmin/$', 'views.myadmin'),
    url(r'^submitloginAmin/$', 'views.submitloginAmin'),
    url(r'^loginPark/$', 'views.loginPark'),
    url(r'^basic/', include('enterprise_basic_information.urls'), name=u'企业基本信息'),
    url(r'^chemicals/', include('enterprise_chemicals.urls'), name=u'化学品信息'),
    url(r'^submitAllMenuByFill/$','views.submitAllMenuByFill'),
    url(r'^register/', 'views.register'),
    url(r'^submitRegister/', 'views.submitRegister'),
    url(r'^facilities/', include('enterprise_facilities.urls')),
    url(r'^dangerous_chemicals/', include('enterprise_dangerous_chemicals.urls')),
    url(r'^pollution/', include('enterprise_pollution_prevention.urls')),
    
    url(r'^park/', include('park.urls'), name=u'园区信息'),
    url(r'^park/chemicals/', include('park_chemicals.urls')),
    url(r'^park/facilities/', include('park_facilities.urls')),
    url(r'^park/data/', include('park_data_detail.urls')),
    url(r'^index2/','views.index2'),

    url(r'^sa/', include('sa.url')),

    url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root':
             os.path.join(os.path.dirname(__file__),'static/').replace('\\','/')
        }),
    url(r'^searchfillInCompany/','views.searchfillInCompany'),
    url(r'^t/', 'urls.test'),
    url(r'^t1/$', 'urls.m1'),
    url(r'^tmap/$', 'urls.tmap'),
    url(r'^tlog/$', 'urls.logtest')
)

from django.shortcuts import *
def m1(request):
    return render_to_response('park/schedules/chemicalPollutionSchedule.html')
    
def tmap(request):
    return render_to_response('enterprise/map/mapNew.html')


def test(request):
    try:
        from enterprise_facilities.models import *
        from util.form_util import *

        pa = ProductArea.objects.get(id=1)
        ps = Production.objects.filter(product_area=pa)

        tpa = pa.clone()
        tpa.save()

        p = ps[0].changeProductArea(tpa)
        p.save()


    except:
        return HttpResponse('123')


def logtest(request):
    from util.log_util import triggerOpLog
    
    flag,msg = triggerOpLog(1,2,3)
    return HttpResponse('%s-%s'%(flag,msg))
